//SUMMARY:  This do files provides replication of findings for Ballard-Rosa, Jensen & Scheve (2021)

//Set directory
cd "C:\Users\cambr\Dropbox\US Authoritarianism\Paper\ISQ\ISQ replication materials\"
global output "C:\Users\cambr\Dropbox\US Authoritarianism\Paper\ISQ\ISQ replication materials\Output" 

use "Data\analysis_data.dta", clear
set scheme s1mono

* Define covariates:
global demo = "female age university_educ college couple children" 
global region = "l_shind_manuf_cbp fb_pct2015 fb_chg_20002015"

lab var female "Female"
lab var age "Age"
lab var university_educ "University"
lab var college "College"
lab var couple "Married"
lab var children "Has children"
lab var l_shind_manuf_cbp "Manufacturing"
lab var shock_v2 "$\Delta$ IP (91-07)"
label var shock_v2_inst "$\Delta$ IPO (91-07)"
lab var ln_shock_v2 "ln $\Delta$ IP (91-07)"
label var highShock "High $\Delta$ IP (91-07)"
lab var diverse "Diversity"
lab var diverse_shock_v2 "Diversity*$\Delta$ IP (91-07)"
label var diverse_shock_v2_inst "Diversity*$\Delta$ IPO (91-07)"
lab var diverse_lnShock "Diversity*ln $\Delta$ IP (91-07)"
lab var diverse_highShock "Diversity*High $\Delta$ IP (91-07)"
lab var fb_pct2015 "% Foreign Born"
lab var fb_chg_20002015 "$\Delta$ % Foreign Born"
label var income_individual "Indiv. income"
label var income_household "HH income"
label var rural_population_pct2010 "Rural pop. (%)"
label var log_totalPop2015 "Total pop. (logged)"

//FIGURE 1:  Trump vote and authoritarianism
lab var trump "Voted for Trump in 2016"

lpoly trump asc, kernel(epanechnikov) degree(0) noscatter title(/*"Authoritarianism and Voting for Trump"*/"") addplot(hist asc, below lcolor(gs13) fcolor(none)) ///
legend(lab(1 "Local polynomial smooth") lab(2 "Density") region(fcolor(white) lcolor(white)) size(small)) note("")
graph export "$output/asc_trump.pdf", replace

//FIGURE 2:  Trade shock exposure by commmuter zone
*See "ISQ generate maps.do"

//TABLE 1: Trade shock and authoritarianism (OLS)
reg asc shock_v2 if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/baseline_asc_white.xls", replace tex(fra) ctitle(ASC) nocons bdec(3) label adds(Commuter zones, e(N_clust))
reg asc shock_v2 diverse diverse_shock_v2 if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/baseline_asc_white.xls", append tex(fra) ctitle(ASC) nocons bdec(3) label adds(Commuter zones, e(N_clust))
reg asc shock_v2 diverse diverse_shock_v2 $demo $region if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/baseline_asc_white.xls", append tex(fra) ctitle(ASC) nocons bdec(3) label adds(Commuter zones, e(N_clust))

//TABLE 2: Trade shock and authoritarianism (IV)
***NOTE:  Layout for this table in text was done by hand; all relevant output produced below
eststo clear
ivreg2 asc (shock_v2 = shock_v2_inst) if white==1 [pweight=weight], cluster(czone) first savefirst savefprefix(alpha)
local fstat = round(e(rkf),.1)
eststo: ivreg2 asc (shock_v2 = shock_v2_inst) if white==1 [pweight=weight], cluster(czone) first savefirst savefprefix(alpha)
outreg2 [alphashock_v2 est1] using  "$output/iv_asc_white", replace nocons ctitle(ASC) tex(frag) bdec(3) label addtext(Weak ID F stat, `fstat')
eststo clear
ivreg2 asc diverse (shock_v2 diverse_shock_v2 = shock_v2_inst diverse_shock_v2_inst) if white==1 [pweight=weight], cluster(czone) first savefirst savefprefix(alpha)
local fstat = round(e(rkf),.1)
eststo: ivreg2 asc diverse (shock_v2 diverse_shock_v2 = shock_v2_inst diverse_shock_v2_inst) if white==1 [pweight=weight], cluster(czone) first savefirst savefprefix(alpha)
outreg2 [alphashock_v2 est1] using  "$output/iv_asc_white", append nocons ctitle(ASC) tex(frag) bdec(3) label addtext(Weak ID F stat, `fstat') sortvar(shock_v2 diverse diverse_shock_v2)
eststo clear
ivreg2 asc diverse (shock_v2 diverse_shock_v2 = shock_v2_inst diverse_shock_v2_inst) $demo $region if white==1 [pweight=weight], cluster(czone) first savefirst savefprefix(alpha)
local fstat = round(e(rkf),.1)
eststo: ivreg2 asc diverse (shock_v2 diverse_shock_v2 = shock_v2_inst diverse_shock_v2_inst) $demo $region if white==1 [pweight=weight], cluster(czone) first savefirst savefprefix(alpha)
outreg2 [alphashock_v2 est1] using  "$output/iv_asc_white", append nocons ctitle(ASC) tex(frag) bdec(3) label addtext(Weak ID F stat, `fstat') sortvar(shock_v2 diverse diverse_shock_v2 $demo $region)

//FIGURE 3: Marginal effect of trade shock exposure on authoritarian values
gen diverseIV = diverse
gen diverseDisp = diverse + .01
label def divLabel 0 "Low diversity" 1 "High diversity"
label val diverseDisp divLabel
* Standardized effect size
egen stdShock = std(shock_v2)
egen stdShockIV = std(shock_v2_inst)
egen stdASC = std(asc)
ivregress 2sls stdASC $demo $region (c.stdShock##diverse = c.stdShockIV##diverseIV) if white==1  [pweight=weight], perfect cluster(czone)
margins, dydx(stdShock) at((mean) _all diverse = (0 1))
marginsplot, yline(0) ytitle(Marginal effect on ASC) xscale(range(-.5 1.5)) xdimension(diverse, elabels(0 "Low diversity" 1 "High diversity") ) recast(scatter) title("") addplot(hist diverseDisp, below frac lcolor(gs13) fcolor(none) yaxis(2) barwidth(.2) xscale(range(-.5 1.5)) xlabel(0 1) yscale(alt range(0 1) axis(2)) ylabel(0(.25)1, axis(2)) leg(off) xsize(4) ysize(4))

//TABLE 3: Trade shock and county average income (by race)
*See "ISQ regional income results.do"

//TABLE 4: Trade shock exposure and voting
***NOTE:  Layout for this table in text was done by hand; all relevant output produced below
reg trump shock_v2 diverse diverse_shock_v2 $demo $region if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/vote_white", replace tex(frag) ctitle(Trump) nocons bdec(3) label adds(Commuter zones, e(N_clust))
eststo clear
ivreg2 trump diverse (shock_v2 diverse_shock_v2 = shock_v2_inst diverse_shock_v2_inst) $demo $region if white==1 [pweight=weight], cluster(czone) first savefirst savefprefix(alpha)
local fstat = round(e(rkf),.1)
eststo: ivreg2 trump diverse (shock_v2 diverse_shock_v2 = shock_v2_inst diverse_shock_v2_inst) $demo $region if white==1 [pweight=weight], cluster(czone) first savefirst savefprefix(alpha)
outreg2 [alphashock_v2 est1] using  "$output/vote_white", append nocons ctitle(Trump) tex(frag) bdec(3) label addtext(Weak ID F stat, `fstat') sortvar(shock_v2 diverse diverse_shock_v2 $demo $region)


//APPENDIX OUTPUT

//FIGURE A1: ASC distribution
label var asc "ASC"
hist asc
graph export "$output/asc_hist.png", replace

//FIGURE A2: Import shock distribution
lab var shock_v2 "Change in Chinese Import Penetration (91-07)"
hist shock_v2
graph export "$output/ip_hist.png", replace
lab var shock_v2 "$\Delta$ IP (91-07)"

//TABLE A2: Summary statistics
summ asc shock_v2 diverse female age university_educ college couple children l_shind_manuf_cbp fb_pct2015 fb_chg_20002015 avg_aggression avg_submission avg_conventionalism

//TABLE A3: Correlation between ASC components
corr avg_aggression avg_submission avg_conventionalism

//TABLE A4: Additional covariates
reg asc shock_v2 diverse diverse_shock_v2 $demo $region income_household if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/moreCovariates_asc_white.xls", replace tex(fra) ctitle(ASC) nocons bdec(3) label adds(Commuter zones, e(N_clust))
reg asc shock_v2 diverse diverse_shock_v2 $demo $region religion_important if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/moreCovariates_asc_white.xls", append tex(fra) ctitle(ASC) nocons bdec(3) label adds(Commuter zones, e(N_clust))
reg asc shock_v2 diverse diverse_shock_v2 $demo $region effort if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/moreCovariates_asc_white.xls", append tex(fra) ctitle(ASC) nocons bdec(3) label adds(Commuter zones, e(N_clust))
* Additional regional covariates:
reg asc shock_v2 diverse diverse_shock_v2 $demo $region rural_population_pct2010 if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/moreCovariates_asc_white.xls", append tex(fra) ctitle(ASC) nocons bdec(3) label adds(Commuter zones, e(N_clust))
reg asc shock_v2 diverse diverse_shock_v2 $demo $region log_totalPop2015 if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/moreCovariates_asc_white.xls", append tex(fra) ctitle(ASC) nocons bdec(3) label adds(Commuter zones, e(N_clust))
reg asc shock_v2 diverse diverse_shock_v2 $demo $region i.regionFE if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/moreCovariates_asc_white.xls", append tex(fra) ctitle(ASC) nocons bdec(3) label adds(Commuter zones, e(N_clust))
* Kitchen sink:
global addDemo "income_household effort religion_important"
global addRegion "rural_population_pct2010 log_totalPop2015 i.regionFE"
reg asc shock_v2 diverse diverse_shock_v2 $demo $addDemo $region $addRegion if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/moreCovariates_asc_white.xls", append tex(fra) ctitle(ASC) nocons bdec(3) label adds(Commuter zones, e(N_clust))

//TABLE A5: Different cutpoints for diversity
gen diverse10pc = (share_white <= .53)
label var diverse10pc "Diversity (10th pc)"
gen diverse25pc = (share_white <= .63)
label var diverse25pc "Diversity (25th pc)"
gen diverse33pc = (share_white <= .67)
label var diverse33pc "Diversity (33rd pc)"
gen diverse50pc = (share_white <= .77)
label var diverse50pc "Diversity (50th pc)"
gen diverse67pc = (share_white <= .83)
label var diverse67pc "Diversity (67th pc)"
gen diverse75pc = (share_white <= .87)
label var diverse75pc "Diversity (75th pc)"
gen diverse90pc = (share_white <= .93)
label var diverse90pc "Diversity (90th pc)"
gen share_nonwhite = 1 - share_white
label var share_nonwhite "% non-white"

reg asc c.shock_v2##diverse10pc $demo $region if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/altDiversity_asc_white.xls", replace tex(fra) ctitle(ASC (OLS)) nocons bdec(3) label adds(Commuter zones, e(N_clust))
reg asc c.shock_v2##diverse25pc $demo $region if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/altDiversity_asc_white.xls", append tex(fra) ctitle(ASC (OLS)) nocons bdec(3) label adds(Commuter zones, e(N_clust))
reg asc c.shock_v2##diverse33pc $demo $region if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/altDiversity_asc_white.xls", append tex(fra) ctitle(ASC (OLS)) nocons bdec(3) label adds(Commuter zones, e(N_clust))
reg asc c.shock_v2##diverse50pc $demo $region if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/altDiversity_asc_white.xls", append tex(fra) ctitle(ASC (OLS)) nocons bdec(3) label adds(Commuter zones, e(N_clust))
reg asc c.shock_v2##diverse67pc $demo $region if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/altDiversity_asc_white.xls", append tex(fra) ctitle(ASC (OLS)) nocons bdec(3) label adds(Commuter zones, e(N_clust))
reg asc c.shock_v2##diverse75pc $demo $region if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/altDiversity_asc_white.xls", append tex(fra) ctitle(ASC (OLS)) nocons bdec(3) label adds(Commuter zones, e(N_clust))
reg asc c.shock_v2##diverse90pc $demo $region if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/altDiversity_asc_white.xls", append tex(fra) ctitle(ASC (OLS)) nocons bdec(3) label adds(Commuter zones, e(N_clust))
reg asc c.shock_v2##c.share_nonwhite $demo $region if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/altDiversity_asc_white.xls", append tex(fra) ctitle(ASC (OLS)) nocons bdec(3) label adds(Commuter zones, e(N_clust))

//TABLE A6: Authoritarian aggression
reg avg_aggression shock_v2 if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/baseline_aggr_white.xls", replace tex(fra) ctitle(Aggr. (OLS)) nocons bdec(3) label adds(Commuter zones, e(N_clust))
reg avg_aggression shock_v2 diverse diverse_shock_v2 if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/baseline_aggr_white.xls", append tex(fra) ctitle(Aggr. (OLS)) nocons bdec(3) label adds(Commuter zones, e(N_clust))
reg avg_aggression shock_v2 diverse diverse_shock_v2 $demo $region if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/baseline_aggr_white.xls", append tex(fra) ctitle(Aggr. (OLS)) nocons bdec(3) label adds(Commuter zones, e(N_clust))
ivreg2 avg_aggression (shock_v2 = shock_v2_inst) if white==1 [pweight=weight], cluster(czone) first savefirst 
local fstat = round(e(rkf),.1)
outreg2 using "$output/baseline_aggr_white.xls", append nocons nor tex(fra) ctitle(Aggr. (IV)) bdec(3) label addtext(Commuter zones, 324, Weak ID F stat, `fstat')
ivreg2 avg_aggression diverse (shock_v2 diverse_shock_v2 = shock_v2_inst diverse_shock_v2_inst) if white==1 [pweight=weight], cluster(czone) first savefirst 
local fstat = round(e(rkf),.1)
outreg2 using "$output/baseline_aggr_white.xls", append nocons nor tex(fra) ctitle(Aggr. (IV)) bdec(3) label addtext(Commuter zones, 324, Weak ID F stat, `fstat') /// 
sortvar(shock_v2 diverse diverse_shock_v2)
ivreg2 avg_aggression diverse (shock_v2 diverse_shock_v2 = shock_v2_inst diverse_shock_v2_inst) $demo $region if white==1 [pweight=weight], cluster(czone) first savefirst 
local fstat = round(e(rkf),.1)
outreg2 using "$output/baseline_aggr_white.xls", append nocons nor tex(fra) ctitle(Aggr. (IV)) bdec(3) label addtext(Commuter zones, 324, Weak ID F stat, `fstat') /// 
sortvar(shock_v2 diverse diverse_shock_v2 $demo $region)

//TABLE A7: Authoritarian submission
reg avg_submission shock_v2 if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/baseline_subm_white.xls", replace tex(fra) ctitle(Subm. (OLS)) nocons bdec(3) label adds(Commuter zones, e(N_clust))
reg avg_submission shock_v2 diverse diverse_shock_v2 if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/baseline_subm_white.xls", append tex(fra) ctitle(Subm. (OLS)) nocons bdec(3) label adds(Commuter zones, e(N_clust))
reg avg_submission shock_v2 diverse diverse_shock_v2 $demo $region if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/baseline_subm_white.xls", append tex(fra) ctitle(Subm. (OLS)) nocons bdec(3) label adds(Commuter zones, e(N_clust))
ivreg2 avg_submission (shock_v2 = shock_v2_inst) if white==1 [pweight=weight], cluster(czone) first savefirst 
local fstat = round(e(rkf),.1)
outreg2 using "$output/baseline_subm_white.xls", append nocons nor tex(fra) ctitle(Subm. (IV)) bdec(3) label addtext(Commuter zones, 324, Weak ID F stat, `fstat')
ivreg2 avg_submission diverse (shock_v2 diverse_shock_v2 = shock_v2_inst diverse_shock_v2_inst) if white==1 [pweight=weight], cluster(czone) first savefirst 
local fstat = round(e(rkf),.1)
outreg2 using "$output/baseline_subm_white.xls", append nocons nor tex(fra) ctitle(Subm. (IV)) bdec(3) label addtext(Commuter zones, 324, Weak ID F stat, `fstat') /// 
sortvar(shock_v2 diverse diverse_shock_v2)
ivreg2 avg_submission diverse (shock_v2 diverse_shock_v2 = shock_v2_inst diverse_shock_v2_inst) $demo $region if white==1 [pweight=weight], cluster(czone) first savefirst 
local fstat = round(e(rkf),.1)
outreg2 using "$output/baseline_subm_white.xls", append nocons nor tex(fra) ctitle(Subm. (IV)) bdec(3) label addtext(Commuter zones, 324, Weak ID F stat, `fstat') /// 
sortvar(shock_v2 diverse diverse_shock_v2 $demo $region)

//TABLE A8: Authoritarian conventionalism
reg avg_conventionalism shock_v2 if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/baseline_conv_white.xls", replace tex(fra) ctitle(Conv. (OLS)) nocons bdec(3) label adds(Commuter zones, e(N_clust))
reg avg_conventionalism shock_v2 diverse diverse_shock_v2 if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/baseline_conv_white.xls", append tex(fra) ctitle(Conv. (OLS)) nocons bdec(3) label adds(Commuter zones, e(N_clust))
reg avg_conventionalism shock_v2 diverse diverse_shock_v2 $demo $region if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/baseline_conv_white.xls", append tex(fra) ctitle(Conv. (OLS)) nocons bdec(3) label adds(Commuter zones, e(N_clust))
ivreg2 avg_conventionalism (shock_v2 = shock_v2_inst) if white==1 [pweight=weight], cluster(czone) first savefirst 
local fstat = round(e(rkf),.1)
outreg2 using "$output/baseline_conv_white.xls", append nocons nor tex(fra) ctitle(Conv. (IV)) bdec(3) label addtext(Commuter zones, 324, Weak ID F stat, `fstat')
ivreg2 avg_conventionalism diverse (shock_v2 diverse_shock_v2 = shock_v2_inst diverse_shock_v2_inst) if white==1 [pweight=weight], cluster(czone) first savefirst 
local fstat = round(e(rkf),.1)
outreg2 using "$output/baseline_conv_white.xls", append nocons nor tex(fra) ctitle(Conv. (IV)) bdec(3) label addtext(Commuter zones, 324, Weak ID F stat, `fstat') /// 
sortvar(shock_v2 diverse diverse_shock_v2)
ivreg2 avg_conventionalism diverse (shock_v2 diverse_shock_v2 = shock_v2_inst diverse_shock_v2_inst) $demo $region if white==1 [pweight=weight], cluster(czone) first savefirst 
local fstat = round(e(rkf),.1)
outreg2 using "$output/baseline_conv_white.xls", append nocons nor tex(fra) ctitle(Conv. (IV)) bdec(3) label addtext(Commuter zones, 324, Weak ID F stat, `fstat') /// 
sortvar(shock_v2 diverse diverse_shock_v2 $demo $region)

//TABLE A9: Non-whites
reg asc shock_v2 if white==0 [pweight=weight], cluster(czone)
outreg2 using "$output/baseline_asc_nonwhite.xls", replace tex(fra) ctitle(ASC (OLS)) nocons bdec(3) label adds(Commuter zones, e(N_clust))
reg asc shock_v2 diverse diverse_shock_v2 if white==0 [pweight=weight], cluster(czone)
outreg2 using "$output/baseline_asc_nonwhite.xls", append tex(fra) ctitle(ASC (OLS)) nocons bdec(3) label adds(Commuter zones, e(N_clust))
reg asc shock_v2 diverse diverse_shock_v2 $demo $region if white==0 [pweight=weight], cluster(czone)
outreg2 using "$output/baseline_asc_nonwhite.xls", append tex(fra) ctitle(ASC (OLS)) nocons bdec(3) label adds(Commuter zones, e(N_clust))
ivreg2 asc (shock_v2 = shock_v2_inst) if white==0 [pweight=weight], cluster(czone) first savefirst 
local fstat = round(e(rkf),.1)
outreg2 using "$output/baseline_asc_nonwhite.xls", append nocons nor tex(fra) ctitle(ASC (IV)) bdec(3) label addtext(Commuter zones, 177, Weak ID F stat, `fstat')
ivreg2 asc diverse (shock_v2 diverse_shock_v2 = shock_v2_inst diverse_shock_v2_inst) if white==0 [pweight=weight], cluster(czone) first savefirst 
local fstat = round(e(rkf),.1)
outreg2 using "$output/baseline_asc_nonwhite.xls", append nocons nor tex(fra) ctitle(ASC (IV)) bdec(3) label addtext(Commuter zones, 177, Weak ID F stat, `fstat') /// 
sortvar(shock_v2 diverse diverse_shock_v2)
ivreg2 asc diverse (shock_v2 diverse_shock_v2 = shock_v2_inst diverse_shock_v2_inst) $demo $region if white==0 [pweight=weight], cluster(czone) first savefirst 
local fstat = round(e(rkf),.1)
outreg2 using "$output/baseline_asc_nonwhite.xls", append nocons nor tex(fra) ctitle(ASC (IV)) bdec(3) label addtext(Commuter zones, 177, Weak ID F stat, `fstat') /// 
sortvar(shock_v2 diverse diverse_shock_v2 $demo $region)

//TABLE A10: Geographic sorting
***NOTE:  Layout for this table in text was done by hand; all relevant output produced below
//Merge in data from ANES
rename countyid2010 cty_fips
merge m:1 cty_fips using "Data\ANES County averages.dta"
gen asc1990s = aggr1990s + subm1990s + conv1990s
* OLS results
reg asc shock_v2 if white==1 & moving==0 [pweight=weight], cluster(czone)
outreg2 using "$output/sameareaOLS_asc_white.xls", replace tex(fra) ctitle(ASC) nocons bdec(3) label adds(Commuter zones, e(N_clust))
reg asc shock_v2 diverse diverse_shock_v2 if white==1 & moving==0 [pweight=weight], cluster(czone)
outreg2 using "$output/sameareaOLS_asc_white.xls", append tex(fra) ctitle(ASC) nocons bdec(3) label adds(Commuter zones, e(N_clust))
reg asc shock_v2 diverse diverse_shock_v2 $demo $region if white==1 & moving==0 [pweight=weight], cluster(czone)
outreg2 using "$output/sameareaOLS_asc_white.xls", append tex(fra) ctitle(ASC) nocons bdec(3) label adds(Commuter zones, e(N_clust))
reg asc shock_v2 diverse diverse_shock_v2 $demo $region asc1990s if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/sameareaOLS_asc_white.xls", append tex(fra) ctitle(ASC) nocons bdec(3) label adds(Commuter zones, e(N_clust))
* IV results
ivreg2 asc (shock_v2 = shock_v2_inst) if white==1 & moving==0 [pweight=weight], cluster(czone) first savefirst 
local fstat = round(e(rkf),.1)
outreg2 using "$output/sameareaIV_asc_white.xls", replace nocons nor tex(fra) ctitle(ASC) bdec(3) label addtext(Commuter zones, 209, Weak ID F stat, `fstat')
ivreg2 asc diverse (shock_v2 diverse_shock_v2 = shock_v2_inst diverse_shock_v2_inst) if white==1 & moving==0 [pweight=weight], cluster(czone) first savefirst 
local fstat = round(e(rkf),.1)
outreg2 using "$output/sameareaIV_asc_white.xls", append nocons nor tex(fra) ctitle(ASC) bdec(3) label addtext(Commuter zones, 209, Weak ID F stat, `fstat') /// 
sortvar(shock_v2 diverse diverse_shock_v2)
ivreg2 asc diverse (shock_v2 diverse_shock_v2 = shock_v2_inst diverse_shock_v2_inst) $demo $region if white==1 & moving==0 [pweight=weight], cluster(czone) first savefirst 
local fstat = round(e(rkf),.1)
outreg2 using "$output/sameareaIV_asc_white.xls", append nocons nor tex(fra) ctitle(ASC) bdec(3) label addtext(Commuter zones, 209, Weak ID F stat, `fstat') /// 
sortvar(shock_v2 diverse diverse_shock_v2 $demo $region)
ivreg2 asc diverse (shock_v2 diverse_shock_v2 = shock_v2_inst diverse_shock_v2_inst) $demo $region asc1990s if white==1 [pweight=weight], cluster(czone) first savefirst 
local fstat = round(e(rkf),.1)
outreg2 using "$output/sameareaIV_asc_white.xls", append nocons nor tex(fra) ctitle(ASC) bdec(3) label addtext(Commuter zones, 751, Weak ID F stat, `fstat') /// 
sortvar(shock_v2 diverse diverse_shock_v2 $demo $region)

//TABLE A11: Bootstrapped estimates
bsweights bsw, reps(50) n(0) nosvy
svyset [pweight=weight], vce(bootstrap) bsrweight(bsw*) strata(czone) singleunit(certainty)
svy: ivregress 2sls asc (shock_v2 = shock_v2_inst) if white==1
outreg2 using "$output/iv_bootstrap", replace nocons ctitle(BS) tex(frag) bdec(3) label adds(Commuter zones, e(N_strata))
ivregress 2sls asc (shock_v2 = shock_v2_inst) if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/iv_bootstrap", append nocons ctitle(SW) tex(frag) bdec(3) label adds(Commuter zones, e(N_clust))
svy: ivregress 2sls asc diverse (shock_v2 diverse_shock_v2 = shock_v2_inst diverse_shock_v2_inst) if white==1
outreg2 using "$output/iv_bootstrap", append nocons ctitle(BS) tex(frag) bdec(3) label adds(Commuter zones, e(N_strata))
ivregress 2sls asc diverse (shock_v2 diverse_shock_v2 = shock_v2_inst diverse_shock_v2_inst) if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/iv_bootstrap", append nocons ctitle(SW) tex(frag) bdec(3) label adds(Commuter zones, e(N_clust))
svy: ivregress 2sls asc diverse $demo $region (shock_v2 diverse_shock_v2 = shock_v2_inst diverse_shock_v2_inst) if white==1
outreg2 using "$output/iv_bootstrap", append nocons ctitle(BS) tex(frag) bdec(3) label adds(Commuter zones, e(N_strata))
ivregress 2sls asc diverse $demo $region (shock_v2 diverse_shock_v2 = shock_v2_inst diverse_shock_v2_inst) if white==1 [pweight=weight], cluster(czone)
outreg2 using "$output/iv_bootstrap", append nocons ctitle(SW) tex(frag) bdec(3) label adds(Commuter zones, e(N_clust))
